﻿using Commons.Helpers;
using Commons.Responses;
using DomainCommons.Models;
using EntityModels.E07.Chats;
using IRepositories;
using ORM;

namespace Repositories
{
    public class ConversationRepository:BaseRepository<int,Conversation>,IConversationRepository
    {
        private readonly PSPDbContext _context;
        public ConversationRepository(PSPDbContext content) : base(content)
        {
            _context = content;
        }

        public override async Task<DataResponse<Conversation>> AddAsync(Conversation ddo)
        {
            try
            {
                _context.Conversations.Add(ddo);
                await _context.SaveChangesAsync();
                return new DataResponse<Conversation>(ddo, "添加成功!");
            }
            catch (Exception ex)
            {
                throw new CustomException("添加失败!");
            }
        }
    }
}
